<?php

// 封装response
function json_res($code,$msg,$data=NULL){
    if($data){
        return response()->json(array('code'=>$code, 'msg'=>$msg, 'data'=>$data));
    }
    return response()->json(array('code'=>$code, 'msg'=>$msg))->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}


function random_string( $length = 16 ) {
    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';//!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
    $password = "";
    for ( $i = 0; $i < $length; $i++ )
    {
        $password .= $chars[ mt_rand(0, strlen($chars) - 1) ];
    }
    return $password;
}

?>
